package com.ruoyi.teaching.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.teaching.mapper.TeachingStudentMapper;
import com.ruoyi.teaching.domain.TeachingStudent;
import com.ruoyi.teaching.service.ITeachingStudentService;
import com.ruoyi.common.core.text.Convert;

/**
 * 教务学员Service业务层处理
 *
 * @author ruoyi
 * @date 2022-10-11
 */
@Service
public class TeachingStudentServiceImpl implements ITeachingStudentService {
    @Autowired
    private TeachingStudentMapper teachingStudentMapper;

    /**
     * 查询教务学员
     *
     * @param studentId 教务学员主键
     * @return 教务学员
     */
    @Override
    public TeachingStudent selectTeachingStudentByStudentId(Long studentId) {
        return teachingStudentMapper.selectTeachingStudentByStudentId(studentId);
    }

    /**
     * 查询教务学员列表
     *
     * @param teachingStudent 教务学员
     * @return 教务学员
     */
    @Override
    public List<TeachingStudent> selectTeachingStudentList(TeachingStudent teachingStudent) {
        return teachingStudentMapper.selectTeachingStudentList(teachingStudent);
    }

    /**
     * 新增教务学员
     *
     * @param teachingStudent 教务学员
     * @return 结果
     */
    @Override
    public int insertTeachingStudent(TeachingStudent teachingStudent) {
        teachingStudent.setCreateTime(DateUtils.getNowDate());
        return teachingStudentMapper.insertTeachingStudent(teachingStudent);
    }

    /**
     * 修改教务学员
     *
     * @param teachingStudent 教务学员
     * @return 结果
     */
    @Override
    public int updateTeachingStudent(TeachingStudent teachingStudent) {
        teachingStudent.setUpdateTime(DateUtils.getNowDate());
        return teachingStudentMapper.updateTeachingStudent(teachingStudent);
    }

    /**
     * 批量删除教务学员
     *
     * @param studentIds 需要删除的教务学员主键
     * @return 结果
     */
    @Override
    public int deleteTeachingStudentByStudentIds(String studentIds) {
        return teachingStudentMapper.deleteTeachingStudentByStudentIds(Convert.toStrArray(studentIds));
    }

    /**
     * 删除教务学员信息
     *
     * @param studentId 教务学员主键
     * @return 结果
     */
    @Override
    public int deleteTeachingStudentByStudentId(Long studentId) {
        return teachingStudentMapper.deleteTeachingStudentByStudentId(studentId);
    }

    /**
     * 根据用户ID查找学生
     *
     * @param userId
     * @return
     */
    @Override
    public TeachingStudent selectTeachingStudentByUserId(Long userId) {
        return teachingStudentMapper.selectTeachingStudentByUserId(userId);
    }
}
